#!/usr/bin/env python
import os
def cleanCscope(path):
  if path == '':
    path = '.'
  #change to target folder
  #store current working directory
  parentDir = os.getcwd()
  os.chdir(path)
  print("clean cscope database and tags under " + os.getcwd())
  if os.path.exists("cscope.files"):
    os.remove("cscope.files")
  if os.path.exists("cscope.in.out"):
    os.remove("cscope.in.out")
  if os.path.exists("cscope.po.out"):
    os.remove("cscope.po.out")
  if os.path.exists("cscope.out"):
    os.remove("cscope.out")
  #back to original directory
  os.chdir(parentDir)

def main(argv):
  if argv == []:
    path = '.'
    cleanCT(path)
  else:
    for path in argv :
      cleanCT(path)


if __name__ == "__main__":
  import sys
  main(sys.argv[1:]) ## sends all but the scriptname as argument
